﻿create or replace package PKG_STDPATTERN_GENERATOR is

  -- Author  : HY
  -- Created : 2012-11-12 오후 12:01:06
  -- Purpose : 패턴생성 패키지 (추가,수정,삭제)

  -- Public function and procedure declarations
  procedure ADD_STDPATTERN_GENERATOR (PATTERN_OBJECTID_IN IN NUMBER, CODE_IN IN VARCHAR2, CREATE_USER_IN NUMBER);
  procedure UPDATE_STDPATTERN_GENERATOR (OBJECTID_IN IN NUMBER, PATTERN_OBJECTID_IN IN NUMBER, CODE_IN IN VARCHAR2, SEQUENCE_IN IN NUMBER, MODIFY_USER_IN IN NUMBER);
  procedure DELETE_STDPATTERN_GENERATOR (OBJECTID_IN IN NUMBER);
  procedure INCSEQ_STDPATTERN_GENERATOR (CODE_IN IN VARCHAR2, RESULT_VAL OUT NUMBER);
end PKG_STDPATTERN_GENERATOR;







create or replace package body PKG_STDPATTERN_GENERATOR as

  -- Function and procedure implementations
  -- 추가
  procedure ADD_STDPATTERN_GENERATOR (PATTERN_OBJECTID_IN IN NUMBER, CODE_IN IN VARCHAR2, CREATE_USER_IN NUMBER) is
  begin
       INSERT INTO STDPATTERN_GENERATOR (OBJECTID, PATTERN_OBJECTID, CODE, CREATE_USER)
       VALUES (SEQ_STDPATTERN_GENERATOR.NEXTVAL, PATTERN_OBJECTID_IN, CODE_IN, CREATE_USER_IN);
  end ADD_STDPATTERN_GENERATOR;

  -- 수정
  procedure UPDATE_STDPATTERN_GENERATOR (OBJECTID_IN IN NUMBER, PATTERN_OBJECTID_IN IN NUMBER, CODE_IN IN VARCHAR2, SEQUENCE_IN IN NUMBER, MODIFY_USER_IN IN NUMBER) is
  begin
       UPDATE STDPATTERN_GENERATOR A SET A.PATTERN_OBJECTID = PATTERN_OBJECTID_IN, A.CODE = CODE_IN, A.SEQUENCE = SEQUENCE_IN, A.MODIFY_DATE = SYSDATE, A.MODIFY_USER = MODIFY_USER_IN WHERE A.OBJECTID = OBJECTID_IN;
  end UPDATE_STDPATTERN_GENERATOR;

  -- 삭제
  procedure DELETE_STDPATTERN_GENERATOR (OBJECTID_IN IN NUMBER) is
  begin
       DELETE FROM STDPATTERN_GENERATOR A WHERE A.OBJECTID = OBJECTID_IN;
  end DELETE_STDPATTERN_GENERATOR;

  -- 시퀀스 증가
  procedure INCSEQ_STDPATTERN_GENERATOR (CODE_IN IN VARCHAR2, RESULT_VAL OUT NUMBER) is
  begin
       UPDATE STDPATTERN_GENERATOR A SET A.SEQUENCE = A.SEQUENCE + 1 WHERE A.CODE = CODE_IN;
       SELECT A.SEQUENCE INTO RESULT_VAL FROM STDPATTERN_GENERATOR A WHERE A.CODE = CODE_IN;
  end INCSEQ_STDPATTERN_GENERATOR;

end PKG_STDPATTERN_GENERATOR;
